package ink.ykb.demo.util;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

/**
 * 分页类
 * @author mading
 *
 * @param <T>
 */
@Data
public class PageInfo<T> implements Serializable{

  private static final long serialVersionUID = 1L;
  
  private Long totalCount;// 总记录数
  
  private Long totalPages;// 总页数
  
  private int pageNumber = 1;//当前页数
  
  private int pageSize = 10;//分页大小
  
  @JsonFormat(with = JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
  private List<T> list = new ArrayList<>();//分页数据
  
  public PageInfo() {
  }
  
  public PageInfo(Integer pageSize, Integer pageNumber) {
    this.pageSize = pageSize;
    this.pageNumber = pageNumber;
  }
  
  public PageInfo(Integer pageSize, Integer pageNumber,List<T> list) {
      this.pageSize = pageSize;
      this.pageNumber = pageNumber;
      this.list = list != null?list:new ArrayList<>();
  }

}
